package com.dyy.proxy.jdk.dynamic;

import java.lang.reflect.Proxy;

import com.dyy.proxy.service.AdminService;
import com.dyy.proxy.service.impl.AdminServiceImpl;

/**
 * @author dingyy@jccfc.com
 * @since 2021/12/12 22:07
 */
public class JdkDynamicProxyTest2 {
    public static void main(String[] args) {
        System.out.println("方法二");
        AdminService adminService = new AdminServiceImpl();
        System.out.println("代理目标类：" + adminService.getClass());
        AdminServiceJdkInvocation adminServiceJdkInvocation = new AdminServiceJdkInvocation(adminService);
        AdminService proxy = (AdminService) Proxy.newProxyInstance(adminService.getClass()
            .getClassLoader(), adminService.getClass()
            .getInterfaces(), adminServiceJdkInvocation);
        System.out.println("代理对象:" + proxy.getClass());
        System.out.println("------------------------");
        proxy.update();
        Object o = proxy.find();
        System.out.println("查找的对象：" + o.getClass());
        System.out.println("------------------------");

    }
}
